package bikeAD;

import io.restassured.RestAssured;
import io.restassured.config.SSLConfig;
import io.restassured.http.ContentType;
import io.restassured.response.Response;

import static io.restassured.RestAssured.given;
import static io.restassured.config.EncoderConfig.encoderConfig;
import static io.restassured.specification.ProxySpecification.host;

public class graphql_method {


    //不带token参数的post请求
    public String graphql_post_without_token(String graphql){
        Response response = given()
                .config(RestAssured.config().encoderConfig(encoderConfig().encodeContentTypeAs("application/graphql", ContentType.JSON)))
                .header("Content-Type","application/graphql")
                .header("Cache-Control","no-cache")
                .body(graphql)
                .when()
                .post("https://b2b-rompers-test.api.ofo.com/graphql");
        //断言登录接口的响应结果状态
        response.then().assertThat().statusCode(200);
        return response.getStatusLine().toString();
    }

    //带token参数的post请求
    public String graphql_post_with_token(String graphql,String token){
        Response response = given()
                .config(RestAssured.config().encoderConfig(encoderConfig().encodeContentTypeAs("application/graphql", ContentType.JSON)))
                .header("Content-Type","application/graphql")
                .header("Cache-Control","no-cache")
                .body(graphql)
                .when()
                .post("https://b2b-rompers-test.api.ofo.com/graphql?token="+token+"");
        //断言登录接口的响应结果状态
        response.then().assertThat().statusCode(200);
        return response.toString();
    }



}
